<%--
  Created by IntelliJ IDEA.
  User: 郑帅
  Date: 2019/8/23
  Time: 22:24
  To change this template use File | Settings | File Templates.
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
<script src="<c:url value="/layui/layui.js"/>"></script>
<link rel="stylesheet" type="text/css" href="<c:url value="/layui/css/layui.css"/>">
<body style="margin: 20px auto;">

<div style="width: 170px; margin-left: 1300px;margin-top: 5px">
    <button type="submit" class="layui-btn layui-btn-fluid"
            onclick="(location.href='${pageContext.request.contextPath}/view/customer/JyjlXJ.jsp?CutId='+${param.CutId})">
        <i class="layui-icon layui-icon-search">新建</i></button>
</div>
<table class="layui-hide" id="test" lay-filter="test" height=100></table>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit" target="_self">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    $(function () {
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#test',
                url: '<c:url value="/Jyjl.do?CutId="/>' +${param.CutId},
                cellMinWidth: 95,
                page: true,
                height: "full-125",
                limits: [5, 10, 15, 20],
                limit: 5,
                id: "userListTable",

                height: "420px",
                response: {
                    statusName: 'code',// 对应 code
                    msgName: 'mag', // 对应 msg
                    countName: 'count', // 对应 count
                    dataName: 'data'  // 对应 data
                }
                ,

                cols: [[

                    // {field: 'stuid', title: 'ID', minWidth:100, align:"center"},
                    // {field: 'stuname', title: '姓名', align:'center'},
                    // {field: 'stuage', title: '年龄', align:'center',minWidth:150},
                    // {fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
                    {field: 'time', title: '时间', minWidth: 100, align: "center", hide: true},
                    {field: 'address', title: '地点', minWidth: 100, align: "center"},
                    {field: 'general', title: '概要', align: 'center'},
                    {field: 'content', title: '详细信息', align: 'center', minWidth: 150},
                    {field: 'remark', title: '备注', minWidth: 100, align: "center"},

                    {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}

                ]]

            });
            table.on('tool(test)', function (obj) {
                var data = obj.data;
                console.log(data.id)
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        obj.del();
                        deleteJyjl(data.id)
                        layer.close(index);
                    });
                } else if (obj.event === 'edit') {
                    customerLoss(obj.data.id);
                }
            });
        });

        function deleteJyjl(id) {
            $.get('<c:url value="/deleteJyjl.do"/>', {"id": id}, function (da) {
                alert("刪除成功");
            })
        }

        function customerLoss(id) {

            location.href = '<c:url value="/LoadJyjl.do?id="/>' + id;

        }

    })
</script>

</body>
</html>
